package Greed;

public class JumpGame1 {
    public boolean canJump(int[] nums) {
          int right=0,left=0,maxpos=0;
          int n=nums.length-1;
          while(left<=right){
              if(maxpos>=n-1){
                  return true;
              }
              for (int i = left; i <= right ; i++) {
                  maxpos=Math.max(maxpos,nums[i]+i);
              }
              left=right+1;
              right=maxpos;
          }
          return false;
    }
}
